package com.molin.StreamTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Stream;

public class Demo2 {
    public static void main(String[] args) {
//        method1();
//        method2();
//        method3();
        method4();
    }

    public static void method4() {
        Stream.of(1,2,3,4,5,6,8).forEach(s-> System.out.println(s));
    }


    public static void method3() {
        int[] arr={1,2,3,4,5};
        Arrays.stream(arr).forEach(s-> System.out.println(s));
    }

    public static void method2() {
        HashMap<String,Integer> hm=new HashMap<>();
        hm.put("zhangsan",23);
        hm.put("li",24);
        hm.put("wang",25);
        hm.put("zhao",26);
        hm.put("qian",27);

        //双列集合不能直接获取Steam流，keySet获取的键放到Steam流中
        //keySet
        hm.keySet().stream().forEach(
                s-> System.out.println(s+hm.get(s))
        );

        //entrySet
        hm.entrySet().stream().forEach(
                s-> System.out.println(s)
        );
    }


    public static void method1() {
        ArrayList<String > list=new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
//        Stream<String> stream=list.stream();
//        stream.forEach((s)->{
//            System.out.println(s);
//        });
        list.stream().forEach(
                s -> System.out.println(s)
        );
    }
}
